package com.yinNuo.collectWool.Task;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author: gjc
 * create at: 2022/6/8 下午2:24
 * @description: 转转赚现金
 */
@Component
@EnableScheduling
@Slf4j
public class zhuanzhuanEarnMoney {
    public static void main(String[] args) {

    //}
    //@Scheduled(cron = "10 6 0 * * ?")//每天凌晨一点十分执行
    //public void zzTask(){

        //签到
        String body1 = "{type: 6,awardContext: {signIndex: 2}}";
        String result1 = zzEarnMoneyUtils(body1);
        log.info("转转签到结果:{}",result1);
        // 签到点击看视频
        String body2 = "{type: 4,awardContext: {awardLimit: 1}}";
        String result2 = zzEarnMoneyUtils(body2);
        log.info("转转签到点击看视频结果:{}",result2);
        // 浏览30秒
        String body3 = "{type: 7,awardContext: {}}";
        String result3 = zzEarnMoneyUtils(body3);
        log.info("转转浏览30秒结果:{}",result3);
        // 看商品得金币×3次
        String body4 = "{type: 2,awardContext: {target: '58803b01-da90-4683-9c61-81fe181fb27f',infoType: 1}}";
        for (int i = 0; i < 3; i++) {
            String result4 = zzEarnMoneyUtils(body4);
            log.info("转转第"+(i+1)+"次看商品得金币结果:{}",result4);
        }
        // 看视频×5次
        String body5 = "{type: 4,awardContext: {}}";
        for (int i = 0; i < 5; i++) {
            String result5 = zzEarnMoneyUtils(body5);
            log.info("转转第"+(i+1)+"次看视频结果:{}",result5);
        }
    }
    /**
    * create by: yinNuo
    * create at: 2022/6/9 22:35
    * description: 封装转转请求
    * @param:  请求体参数 json字符串
    * @return:
    */
    public static String zzEarnMoneyUtils(String body){
        //转转签到
        String body1 = HttpRequest.post("https://app.zhuanzhuan.com/zzopen/bizinfoshow/makeMoneyAward")
                //.header(Header.CONTENT_TYPE, "application/json")
                //.header(Header.ACCEPT_ENCODING, "gzip, deflate, br")
                //.header(Header.CONNECTION, "keep-alive")
                //.header(Header.ACCEPT,"application/json, text/plain, */*")
                //.header(Header.ACCEPT_LANGUAGE,"zh-CN,zh-Hans;q=0.9")
                //.header(Header.CONTENT_LENGTH, "41")
                .header(Header.COOKIE, "PPU=\"TT=49f4aeb8c5d270d569fb03e4412a65d8824980f5&UID=11214649081004800&CT=1654665957229&SF=ZHUANZHUAN&SCT=1654669557229&V=2&ET=1657257957229&AP=16\";")
                                            //PPU="TT=2b3bb8666d26dbb5efeec114967b70222768ad6e&UID=11214649081004800&CT=1654821875244&SF=ZHUANZHUAN&SCT=1654825475244&V=2&ET=1657413875244&AP=16";
        //.header("Csrf-Token","49f4aeb8c5d270d569fb03e4412a65d8824980f5")
                //.header(Header.HOST,"app.zhuanzhuan.com")
                //.header(Header.ORIGIN,"https://m.zhuanzhuan.com")
                //.header(Header.REFERER,"https://m.zhuanzhuan.com")
                //.header(Header.USER_AGENT,"Mozilla/5.0 (iPhone; CPU iPhone OS 15_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 zzVersion/9.10.0 zzT/16 zzDevice/1_141.0_3.0 zzApp/58ZhuanZhuan")
                //.body("{\"type\": 6,\"awardContext\": {\"signIndex\": 1}}").execute().body(); //签到
                //.body("{\"type\": 4,\"awardContext\": {\"awardLimit\": 1}}").execute().body(); //浏览商品
                //.body("{\n" +
                //        "  \"type\": 2,\n" +
                //        "  \"awardContext\": {\n" +
                //        "    \"target\": \"c2b78dfb-f02d-4e50-a453-6aa5dbd042ac\",\n" +
                //        "    \"infoType\": 1\n" +
                //        "  }\n" +
                //        "}").execute().body();
                .body(body).execute().body();
        return body1;
    }

}
